package com.example.dto;

import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import org.springframework.security.oauth2.jose.jws.SignatureAlgorithm;

import java.io.IOException;

public class SignatureAlgorithmDeSerializer extends JsonDeserializer<SignatureAlgorithm> {

    @Override
    public SignatureAlgorithm deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JacksonException {
        String text = jsonParser.getText();
        return SignatureAlgorithm.from(text);
    }
}
